<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .red {
      color: red;
    }
    .bigfont {
      font-size: 60px;
    }
  </style>
</head>
<body>
  <div id="app">
    <p>vue绑定class和style</p>
    <div :class="class1">变量替换</div>
    <div :class="size+'font'">字符串拼接</div>
    <div :class="isLogin?'login':'notLogin'">三元表达式</div>
    <div :class="{active: isActive}">对象的判断,对象的属性值为真时，有这个class；否则没有</div>
    <div :class="[{active: isActive}, isLogin?'login':'notLogin', 'top', class1]">好多个class</div>
    <button v-for="num in 4" :class="{red: num == 1}">{{num}}</button>
    <button v-for="num in 4" :class="'class'+num">{{num}}</button>
    <hr>
    <div :style="{color: colorBlue, 'font-size': fontSize}">绑定style</div>
    <div :style="{'font-size': font+'px'}">字符串拼接</div>
    <div :style="style1">整个style全部替换</div>
    <div :style="[style1, style2]">数组的形式</div>
    <input type="text" v-model="msg" @input="change(777, $event)">
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        msg: '666',
        class1: 'red',  
        size: 'big',
        isLogin: true,
        isActive: true,
        colorBlue: 'blue',
        fontSize: '100px',
        font: 60,
        style1: {
          'font-weight': 900,
          'font-style': 'italic'
        },
        style2: {
          border: '2px solid red',
        },
      },
      methods: {
        change(num, e) {
          console.log(e.target.value);
          console.log(num);
        }
      },
    })
  </script>
</body>
</html>